package com.yzy.demo.vo;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回值封装类
 *
 * @author 杨志远
 * @date 2025/4/5 11:11
 */
@Data
public class Result {

    private Integer code;
    private String msg;

    private Map<String, Object> data = new HashMap<>(16);

    public static Result ok() {
        Result result = new Result();
        result.setCode(200);
        result.setMsg("支付成功");
        return result;
    }

    public static Result error() {
        Result result = new Result();
        result.setCode(500);
        result.setMsg("支付失败");
        return result;
    }

    /**
     * 和上面的实例化赋值作用是一样的
     * @param key
     * @param value
     * @return
     */
    public Result data(String key, Object value) {
        this.data.put(key, value);
        return this;
    }
}
